package org.easy.liblibai;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;


@Configuration
@EnableConfigurationProperties({LibLibAiProperties.class})
@ConditionalOnProperty(prefix = LibLibAiProperties.PREFIX, name = "enabled", havingValue = "true")
public class LibLibAiAutoConfiguration {

    @Resource
    private LibLibAiProperties libLibAiProperties;

    @Bean
    public LibLibAiTemplate libLibAiTemplate() {
        LibLibAiClient libLibAiClient = new LibLibAiClient(libLibAiProperties.getAccessKey(), libLibAiProperties.getSecretKey());
        return new LibLibAiTemplate(libLibAiClient);
    }

}
